let alldata=[]
let nowpage=1;
        let content = "`"+
            '<tr class="mwidth">'+
                '<td>'+
                    '<input type="checkbox" id="" value="" class="box-checkbox">'+
                '</td>'+
                '<td>${data[i].退货单号}</td>'+
                '<td>${data[i].快递单号}</td>'+
                '<td>${data[i].申请时间}</td>'+
                '<td>${data[i].商品数量}</td>'+
                '<td>${data[i].退款金额}</td>'+
                '<td>${data[i].退货原因}</td>'+
                '<td>${data[i].退货状态}</td>'+
                '<td>'+
                    '<a onclick="order(this)">查看详情</a>  '  +
                '</td>'+
            '</tr>'+'`'
            let pagecontent = "`"+
                    "<li>"+
                        "${i+1}"+
                    "</li>"
                    +"`" 
                    let names=[
                        {
                            "name":'全部',
                            "data":"all"
                        },
                        {
                            "name":'待审核',
                            "data":"待付款"
                        },
                        {
                            "name":'待收货',
                            "data":"待发货"
                        },
                        {
                            "name":'待退款',
                            "data":"待收货"
                        },
                        {
                            "name":'待到账',
                            "data":"待评价"
                        },
                        {
                            "name":'完成',
                            "data":"已完成"
                        },
                        {
                            "name":'拒绝退货',
                            "data":"已取消"
                        },
                    ]
window.onload=function(){
    $('.daochub').on('click',function(){
        $('.daochu').modal('toggle')
    })
    alldata=data
    for(let i=0;i<names.length;i++){
        checkshow(alldata,names[i].name,names[i].data)
    }
    $('.label-page').on('click','div',function(){
        check($(this),alldata,'.pagenum',".mtable",parseInt($('#page_num').find("option:selected").val()),pagecontent,content)
    })
    init(alldata,'.pagenum',".mtable",parseInt($('#page_num').find("option:selected").val()),pagecontent,content,1)
    allcheck()
    $('#page_num').on('change',function(){
        init(alldata,'.pagenum',".mtable",parseInt($(this).find("option:selected").val()),pagecontent,content,1)
    })
    $('.reset').on('click',()=>{
        let querys = $('.mcol').find('.minput');
        let x = parseInt($('#page_num').find("option:selected").val())
        let option;
        for(let i=0;i<$('.label-page').find('div').length;i++){
            if($($('.label-page').find('div')[i]).attr('class')=='hshow'){
                option=$($('.label-page').find('div')[i])
                break;
            }
        }
        for(let i=0;i<querys.length;i++){
            $(querys[i]).val('')
        }
        check(option,alldata,'.pagenum',".mtable",x,pagecontent,content)
    })
    remove(alldata,'.pagenum',".mtable",parseInt($('#page_num').find("option:selected").val()),pagecontent,content,1)
    $('.daying').on('click',function(){
        let dels=[]
        let msg=[]
        for(let i=0;i<$('tbody>.mwidth>td').find('input').length;i++){
            if($($('tbody>.mwidth>td').find('input')[i]).prop('checked')){
                dels.push($($($('tbody>.mwidth>td').find('input')[i]).parent().parent().find('td')[1]).text())
            }
        }
        for(let j=0;j<dels.length;j++){
            for(let i=0;i<alldata.length;i++){
                if(alldata[i].退货单号==dels[j]){
                    msg.push(alldata[i])
                }
            }
        }
        sessionSet('msg',msg)
        location.href='../tuihuanhuo/Tpiliangshouhuo.html'
    })
    $('.piliang').on('click',function(){
        let dels=[]
        let msg=[]
        for(let i=0;i<$('tbody>.mwidth>td').find('input').length;i++){
            if($($('tbody>.mwidth>td').find('input')[i]).prop('checked')){
                dels.push($($($('tbody>.mwidth>td').find('input')[i]).parent().parent().find('td')[1]).text())
            }
        }
        for(let j=0;j<dels.length;j++){
            for(let i=0;i<alldata.length;i++){
                if(alldata[i].退货单号==dels[j]){
                    msg.push(alldata[i])
                }
            }
        }
        sessionSet('msg',msg)
        location.href='../tuihuanhuo/Tpiliangtuikuan.html'
    })
}

function check(el,data,pagelocation,contentloaction,pagesnum,pagecontent,content){
    for(let i=0;i<el.parent().find('div').length;i++){
        $(el.parent().find('div')[i]).removeClass('hshow')
    }
    el.addClass('hshow')
    if($(el.find('span')[0]).text()!="全部"){
        let datas = data.filter(item => item.订单状态==$(el.find('span')[0]).text())
        init(datas,pagelocation,contentloaction,pagesnum,pagecontent,content,1)
    }else{
        init(data,pagelocation,contentloaction,pagesnum,pagecontent,content,1)
    }
}

function init(data,pagelocation,contentloaction,pagesnum,pagecontent,content,nowpage){
    $('.query').off('click')
    $('.query').on('click',function(){
        query(data,pagelocation,contentloaction,pagesnum,pagecontent,content,nowpage)
    })
    page(data,contentloaction,pagesnum,content,nowpage)
    pagenum(data,pagelocation,pagesnum,pagecontent)
    ingo(data,pagelocation,contentloaction,pagesnum,pagecontent,content)
    back(data,pagelocation,contentloaction,pagesnum,pagecontent,content)
    next(data,pagelocation,contentloaction,pagesnum,pagecontent,content)
}

function query(data,pagelocation,contentloaction,pagesnum,pagecontent,content,nowpage){
    let querys = $('.mcol').find('.minput');
    let names = $('.mcol').find('span')
    let ns=[]
    let values = [];
    let datas=data
    for(let i=0;i<querys.length;i++){
        values.push($(querys[i]).val());
        ns.push($(names[i]).text())
    }
    for(let i=0;i<values.length;i++){
        if(ns[i]=="退货单号"){
            values[i]=values[i].slice(0,5)+""+values[i].slice(5,9)+""+values[i].slice(9,12)
        }
        if(values[i]!="快递单号"&&values[i]!=""&&values[i]!=null){
            datas=datas.filter(item => item[ns[i]]==values[i])
        }
    }
    init(datas,pagelocation,contentloaction,pagesnum,pagecontent,content,nowpage)
}
function remove(datas,pagelocation,contentloaction,pagesnum,pagecontent,content,nowpage){
    let dels=[]
    $('.del').on('click',function(){
        for(let i=0;i<$('tbody>.mwidth>td').find('input').length;i++){
            if($($('tbody>.mwidth>td').find('input')[i]).prop('checked')){
                dels.push($($($('tbody>.mwidth>td').find('input')[i]).parent().parent().find('td')[1]).text())
            }
        }
        for(let j=0;j<dels.length;j++){
            for(let i=0;i<datas.length;i++){
                if(datas[i].退货单号==dels[j]){
                    datas.splice(i,1)
                }
            }
        }
        for(let i=0;i<$('.allcheck').length;i++){
            $($('.allcheck')[i]).prop('checked', false)
        }
        $('.label-page').text('')
        for(let i=0;i<names.length;i++){
            checkshow(alldata,names[i].name,names[i].data)
        }
        init(datas,pagelocation,contentloaction,pagesnum,pagecontent,content,nowpage)
    })
}

function order(e){
    let item = alldata.filter(item => item.退货单号==$($(e).parent().parent().find('td')[1]).text())
    sessionSet('msg',item[0])
    location.href='../../html/orderform/order.html'
}